package com.zareal.feign;

import com.zareal.dot.GetProductDto;
import com.zareal.enums.GlobalErrorCode;
import com.zareal.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component

public class StorageFeignClientFallbackFactory implements FallbackFactory<StorageFeignClient> {
    @Override
    public StorageFeignClient create(Throwable throwable) {
        return new StorageFeignClient() {
            @Override
            public JSONResult get(Long id) {
                JSONResult jsonResult = new JSONResult();
                return JSONResult.success(GlobalErrorCode.SERVICE_ERROR);
            }

            @Override
            public JSONResult list() {
                JSONResult jsonResult = new JSONResult();
                return JSONResult.success(GlobalErrorCode.SERVICE_ERROR);
            }

            @Override
            public JSONResult putStorage(GetProductDto getProductDto) {
                return JSONResult.success(GlobalErrorCode.STORE_PUT_ERROR);
            }

            @Override
            public JSONResult outStorage(GetProductDto getProductDto) {
                return JSONResult.success(GlobalErrorCode.STORE_OUT_ERRORR);
            }
        };
    }
}
